var channelTable;

function initChannelTable() {
	channelTable = right_table_layout.attachGrid();
	channelTable.setIconsPath(contextPath
			+ '/resources/common/js/dhtmlx_std_full/imgs/');

	channelTable.setHeader('DEVICE ID, CHANNEL ID, NAME, MAX_VAL, MIN_VAL');
	channelTable.setInitWidths('100, 100, 400, 200, 200');
	channelTable.setColAlign('left, left, left, left, left');
	channelTable.setColSorting('int, int, str, int, int');
	channelTable.init();

	channelTable.attachEvent('onRowSelect', function(id, ind) {
		var selId = channelTable.getCombo(id);
		console.log(selId);
		dataStore.put('chartId', id);
		channelChart.clearAll();
		createChart(true);
	});
}

function createChannelTable(id) {
	channelTable.clearAll();
	var tableRequest = $.ajax({
		url : '/bwf/channel/' + id,
		type : 'GET',
		dataType : 'json'
	});
	tableRequest.done(function(info) {
		for (var i = 0; i < info.length; i++) {
			data = info[i];
			console.log(data);
			channelTable.addRow(i + 1, [ data['deviceId'], data['id'],
					data['name'], data['maxVal'], data['minVal'] ]);
		}
	});
	tableRequest.fail(function(jqXHR, textStatus) {
		alert('Request failed!');
	});
}